<?php
class MenuModel extends Model{
    protected $fields=array(
        'id','pid','name','rank','level','ismenu','url',
        '_pk'=>'id',
        '_autoInc'=>true
    );

    public function getPopedomTree(){
        $popedom=$this->order('pid asc,rank asc')->field('id,name,pid')->findAll();
        if($popedom){
            require CONF_DIR.'/MenuI18n.php';
            $all=array();
            foreach($popedom as $pope){
                if($pope['pid']==0){
                    $all[$pope['id']]['name']=L($pope['name']);
                }else{
                    $all[$pope['pid']]['sub'][]=array('id'=>$pope['id'],'name'=>L($pope['name']));
                }
            }
            return $all;
        }
        return false;
    }
}
